﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Jermaine.UI
{
    /// <summary>
    /// Borderless Form
    /// Jermaine 2014-4-14
    /// </summary>
    public partial class BorderlessForm : Form
    {
        private const int WM_NCHITTEST = 0x0084;
        public BorderlessForm() {
            InitializeComponent();
        }

        /// <summary>
        /// override the win32 message to capture the mouse message
        /// </summary>
        /// <param name="m"></param>
        protected override void WndProc(ref Message m) {
            base.WndProc(ref m);
            if (m.Msg == WM_NCHITTEST) {
                switch (m.Result.ToInt32()) {
                    case 1:
                        m.Result = new IntPtr(2);
                        break;
                }
            }
        }
    }
}
